package site.kitcheng.springboottest.infra.config.Quartz;

import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import site.kitcheng.springboottest.infra.config.Quartz.job.MySystemJob;

/**
 * ClassName: QuartzConfig
 * Package: site.kitcheng.springboottest.infra.config.Quartz
 * Description:
 *
 * @Author jiangCheng
 * @Create 2025/2/24 15:07
 * @Version 1.0
 */
//@Configuration
public class QuartzConfig {
    @Bean
    public JobDetail myJobDetail() {
        return JobBuilder.newJob(MySystemJob.class)
                .withIdentity("MySystemJob")
                .storeDurably()
                .build();
    }

    @Bean
    public Trigger myTrigger() {
        SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule()
                .withIntervalInSeconds(10)
                .repeatForever();

        return TriggerBuilder.newTrigger()
                .forJob(myJobDetail())
                .withIdentity("myTrigger")
                .withSchedule(scheduleBuilder)
                .build();
    }
}